package com.example.keli.ui.my;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.example.keli.R;
import com.example.keli.base.BaseActivity;
import com.example.keli.ui.home.activity.ObjectDetailActivity;

import butterknife.BindView;

public class H5Activity extends BaseActivity {

    public static final String AGENT_URL = "http://keli.h5ck.com/agent.html ";//可哩经纪人
    public static final String PLAYER_NOTICE_URL = "http://keli.h5ck.com/notes.html ";//收益分成须知

    @BindView(R.id.webView)
    WebView webView;
    private String mUrl = AGENT_URL;

    public static void start(Context context, String url) {
        Intent intent = new Intent(context, H5Activity.class);
        intent.putExtra("url", url);
        context.startActivity(intent);
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_h5;
    }

    @Override
    protected void bindData() {
        mUrl = getIntent().getStringExtra("url");
        String title = AGENT_URL.equals(mUrl)?"可哩经纪人":"可哩短视频选手须知";
        abTitle.setText(title);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setDefaultTextEncodingName("UTF-8");
        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        webView.setWebChromeClient(new WebChromeClient());
        webView.loadUrl(mUrl);
    }
}
